# Contributor: Sander Maijers <S.N.Maijers+Alpine@gmail.com>
# Maintainer: Krassy Boykinov <kboykinov@teamcentrixx.com>
pkgname=xmlsec
pkgver=1.3.2
pkgrel=0
pkgdesc="C based implementation for XML Signature Syntax and Processing and XML Encryption Syntax and Processing"
url="https://github.com/lsh123/xmlsec/"
arch="all"
license="MIT"
makedepends="
	libtool
	libxml2-dev
	libxslt-dev
	nss-dev
	openssl-dev>3
	"
checkdepends="nss-tools"
subpackages="$pkgname-nss $pkgname-dev $pkgname-doc"
source="https://github.com/lsh123/xmlsec/releases/download/xmlsec_${pkgver//./_}/xmlsec1-$pkgver.tar.gz"
builddir="$srcdir/xmlsec1-$pkgver"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--disable-static \
		--enable-pkgconfig \
		--with-openssl=/usr \
		--without-gnutls \
		--without-gcrypt \
		--with-default-crypto=openssl
	make
}

check() {
	make -k check
}

package() {
	make DESTDIR="$pkgdir" install
}

dev() {
	default_dev

	# move plugin back, as the library opens this itself with bare .so
	mv "$subpkgdir"/usr/lib/libxmlsec1-openssl.so "$pkgdir"/usr/lib
}

nss() {
	pkgdesc="xmlsec nss plugin"
	install_if="$pkgname=$pkgver-r$pkgrel nss"

	amove usr/lib/libxmlsec1-nss.so*
}

sha512sums="
328f3d27cc1dadee27e5ee4649f6c5a094203cc27f42f1fe98fd429f7dd5630eaadff0e8bf14616016fc3530482ed8bcee4870289a41a083f6dd9bd603782a92  xmlsec1-1.3.2.tar.gz
"
